//var fps = 50;
var canvas = document.createElement("canvas");
var ctx = canvas.getContext("2d");
var mouseX=0;
var mouseY=0;
canvas.width = 800;
canvas.height = 600;
document.body.appendChild(canvas);

var bgready = false;
// Background image
var bgImage = new Image();
bgImage.onload = function() {
	bgready = true;
	//ctx.drawImage(bgImage, 0, 0);
};
bgImage.src = "icon/newbg2.png";

var logoImage = new Image();
logoImage.onload = function() {
	//ctx.drawImage(exImage, 227, 460);
};
logoImage.src = "icon/Newlogo.png";

var exImage = new Image();
exImage.onload = function() {
	//ctx.drawImage(exImage, 227, 460);
};
exImage.src = "icon/exit-button.png";

var playImage = new Image();
playImage.onload = function(){
	
};
playImage.src = "icon/play-button.png";

function draw(){
	ctx.drawImage(bgImage, 0, 0);
	if(bgready){
		ctx.drawImage(exImage, 85, 405);
		ctx.drawImage(playImage, 85, 325);
		ctx.drawImage(logoImage,0,0);
		

	}
}
var decor = "width=800,height=600";
function tap(e){
	
	mouseX = e.pageX;
	mouseY = e.pageY;
	
	if(mouseX>=85 && mouseX<=431 &&mouseY>=325 && mouseY<=390)
		window.open("maingame.html",'_self',decor);
	else if(mouseX>=85 && mouseX<=431 &&mouseY>=405 && mouseY<=470){
		var result = window.confirm("Want to leave this game?");
		if(result == ture)
			window.close();
		else{}
		
		}
	//else if(mouseX>=85 && mouseX<=431 &&mouseY>=485 && mouseY<=550)
	
	};
	


document.addEventListener("mousedown", tap);
//document.addEventListener("onmousemove", setcur);



bgImage.addEventListener("load", draw);
